<template>
  <div class="divBox relative">
    <el-card class="box-card">
      <div class="clearfix">
        <div class="container">
          <el-form size="small" label-width="100px">
            <el-form-item label="订单号：" class="width100">
              <el-input v-model="tableFrom.orderNo" placeholder="请输入订单号" class="selWidth" size="small" clearable>
                <el-button slot="append" icon="el-icon-search" size="small" @click="seachList" />
              </el-input>
            </el-form-item>
          </el-form>
        </div>
      </div>
    </el-card>
    <div class="mt20">
      <!-- <cards-data :cardLists="cardLists" v-if="checkPermi(['admin:order:list:data'])"></cards-data> -->
    </div>
    <el-card class="box-card">
      <el-table v-loading="listLoading" :data="tableData.data" size="mini" class="table" highlight-current-row
                :header-cell-style="{ fontWeight: 'bold' }">
        <el-table-column prop="orderNo" label="订单号" min-width="210"></el-table-column>
        <el-table-column prop="orderStatus" label="订单状态" min-width="150" />
        <el-table-column prop="jdName" label="酒店名称" min-width="150" />
        <el-table-column prop="jdfxName" label="酒店房型名称" min-width="150" />
        <el-table-column prop="rlTime" label="入离时间" min-width="150" />
        <el-table-column prop="jianshu" label="间数" min-width="150" />
        <el-table-column prop="gmTime" label="购买时间" min-width="150" />
        <el-table-column prop="ruzhuren" label="入住人" min-width="150" />
        <el-table-column prop="lianxiren" label="联系人" min-width="150" />
        <el-table-column prop="userPhone" label="用户手机号" min-width="150" />
        <el-table-column label="操作" min-width="150" fixed="right" align="center">
          <template slot-scope="scope">
            <router-link :to="{ path: '/amszs/order/orderDetail/' + scope.row.id }">
              <el-button type="text" size="small" class="mr10" v-hasPermi="['admin:msOrder:info']">详情</el-button>
            </router-link>
            <!-- 编辑-->
            <el-button type="text" size="small" class="mr10" @click="edit(scope.row)">编辑</el-button>
            <el-button type="text" size="small" class="mr10" @click="deleted(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination :page-sizes="[20, 40, 60, 80]" :page-size="tableFrom.limit" :current-page="tableFrom.page"
                       layout="total, sizes, prev, pager, next, jumper" :total="tableData.total" @size-change="handleSizeChange"
                       @current-change="pageChange" />
      </div>
    </el-card>

    <!--编辑-->
    <order-edit ref="orderEditRef" :editData="editData" />
  </div>
</template>

<script>
import { orderListApi,orderDeleteApi,getOrderByIdApi} from '@/api/msOrder'
import detailsFrom from './orderDetail'
import orderEdit from './orderEdit'
export default {
  name: 'orderlistDetails',
  components: {
    detailsFrom,
    orderEdit
  },
  data() {
    return {
      tableData: {
        data: [],
        total: 0
      },
      listLoading: true,
      tableFrom: {
        "orderNo": '',
        "limit": 10,
        "page": 1
      },
      editData: {},
      orderEditRef:false
    }
  },
  mounted() {
    this.getList();
  },
  methods: {
    resetForm(formValue) {
      this.dialogVisible = false
    },
    seachList() {
      this.tableFrom.page = 1
      this.getList()
    },
    // 编辑
    async edit(row) {
      // this.orderEditRef = true;
      this.$refs.orderEditRef.dialogVisible = true;
      this.editData = await getOrderByIdApi({id:row.id})
    },
    // 删除
    deleted(row) {
      this.$modalSure(`删除 订单号 为 ${row.orderNo} 的数据吗`).then(() => {
        orderDeleteApi({id:row.id}).then(() => {
          this.$message.success('删除成功')
          this.getList()
        })
      })
    },
    // 获取订单列表
     getList() {
      this.listLoading = true
        orderListApi(this.tableFrom).then(res => {
        this.tableData.data = res.list || [];
        this.tableData.total = res.total;
        this.listLoading = false
      }).catch(() => {
        this.listLoading = false
      })
    },
    pageChange(page) {
      this.tableFrom.page = page
      this.getList()
    },
    handleSizeChange(val) {
      this.tableFrom.limit = val
      this.getList()
    },
  }
}
</script>
<style lang="scss" scoped>
.el-table__body {
  width: 100%;
  table-layout: fixed !important;
}

.demo-table-expand {
  ::v-deeplabel {
    width: 83px !important;
  }
}

.refunding {
  span {
    display: block;
  }
}

.selWidth {
  width: 300px;
}

.el-dropdown-link {
  cursor: pointer;
  color: #409EFF;
  font-size: 12px;
}

.el-icon-arrow-down {
  font-size: 12px;
}

.tabBox_tit {
  font-size: 12px !important;
  /*margin: 0 2px 0 10px;*/
  letter-spacing: 1px;
  /*padding: 5px 0;*/
  box-sizing: border-box;
}

.text_overflow {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

.pup_card {
  width: 200px;
  border-radius: 5px;
  padding: 5px;
  box-sizing: border-box;
  font-size: 12px;
  line-height: 16px;
}

.flex-column {
  display: flex;
  flex-direction: column;
}

.mt20 {
  margin-top: 20px
}

.relative {
  position: relative;
}
</style>
